package com.LA_houseLease.app.controller.history;



import com.LA_houseLease.app.service.BrowsingHistoryService;
import com.LA_houseLease.app.vo.history.HistoryItemVo;
import com.LA_houseLease.common.context.BaseContext;
import com.LA_houseLease.common.result.Result;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin(origins = "*")
@Slf4j
@RestController
@Tag(name = "浏览历史管理")
@RequestMapping("/app/history")
public class BrowsingHistoryController {

    @Autowired
    private BrowsingHistoryService browsingHistoryService;
    @Operation(summary = "获取浏览历史")
    @GetMapping("pageItem")
    private Result<IPage<HistoryItemVo>> page(@RequestParam long current, @RequestParam long size) {
        log.warn("获取浏览历史--BrowsingHistoryController.page");
        Page<HistoryItemVo> page = new Page<>(current, size);
        Long userId = BaseContext.getLoginUser().getUserId();
        IPage<HistoryItemVo> result=browsingHistoryService.pageHistoryItemVo(page,userId);
        return Result.ok(result);
    }
}
